﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Threading;

namespace VDataAdapter
{
    class MarketInfoWorker : Worker
    {
        protected VdataCommunicator _sender;

        public MarketInfoWorker(ManualResetEvent waitFirstTime, VdataCommunicator sender) : base(waitFirstTime, null)
        {
            _sender = sender;
        }

        protected override void DoWork(object data)
        {
            var maketinfos = (IDictionary<int, PriceLibrary.PriceService.StockBase>)data;
            int key;

            foreach (KeyValuePair<int, PriceLibrary.PriceService.StockBase> p in maketinfos)
            {
                key = p.Key;
                PriceLibrary.PriceService.MarketInfo marketInfo = (PriceLibrary.PriceService.MarketInfo)p.Value;
                
                // marketInfoNew.TotalShares *= 10; // Vdata already did this
                
                _sender.SendMarketInfo(key, marketInfo);
            }

        }

    }
}
